package iterator.improve;


import java.util.Iterator;

/**
 * 计算机学院,ConcreteAggregate
 */
public class ComputerCollege implements College {
    // 维护一个院系
    private final Department[] departments;
    // 维护一个下标索引
    private int index = 0;

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment(new Department("Java专业", " Java专业 "));
        addDepartment(new Department("PHP专业", " PHP专业 "));
        addDepartment(new Department("大数据专业", " 大数据专业 "));
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public Iterator<Department> createIterator() {
        return new ComputerCollegeIterator(departments);
    }

    @Override
    public void addDepartment(Department department) {
        departments[index] = department;
        index++;
    }
}
